const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default
const TransformPages = require('uni-read-pages')
const {
  webpack
} = new TransformPages()

module.exports = {
  parallel: false,
  configureWebpack: {
    plugins: [
      ScriptSetup({
        /* options */
      }),
      new webpack.DefinePlugin({
        ROUTES: webpack.DefinePlugin.runtimeValue(() => {
          const tfPages = new TransformPages({
            includes: ['path', 'name', 'meta', 'aliasPath']
          })
          return JSON.stringify(tfPages.routes)
        }, true)
      })
    ]
  },
  chainWebpack(config) {
    // disable type check and let `vue-tsc` handles it
    config.plugins.delete('fork-ts-checker')
  }
}
